﻿#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_

#include <QWidget>
#include <QWebSocket>
#include <QWebSocketServer>
#include <QHash>

#include <QListView>
#include <QStandardItemModel>
#include <QHBoxLayout>



class Server : public QWidget
{
	Q_OBJECT

public:
	QWebSocketServer* m_webSocketServer{};
	QHash<QString, QWebSocket* > m_websocketclient;

	QStandardItemModel* m_listModel{};
	QListView* m_listview{};

	int connectionnumber = 0;
public:
	Server(QWidget* parent = nullptr);
	~Server();

	void init();
	bool start(const QHostAddress& address, quint16 port);
	void layoutinit();
	void UpdateView(QString connectdata = "the network is connected!");



public slots:
	void onNewConnection();
	void onDisConnecttion();
	void onBinaryMessageRecived(const QByteArray& data);
	void onTextMessageRecived(const QString& data);

signals:
	void data(QString);

};


#endif // !MAINWINDOW_H_
